<%@ Page Title="<%$Resources:Language,CmsNewsEditTitle %>" Language="C#" MasterPageFile="~/cms.master"
    AutoEventWireup="true" CodeFile="Poll.aspx.cs" Inherits="PollEdit" %>

<%@ Register Src="~/controls/ctrlShowInfo.ascx" TagName="ctrlShowInfo" TagPrefix="ctrl" %>
<%@ Register Assembly="Winthusiasm.HtmlEditor" Namespace="Winthusiasm.HtmlEditor"
    TagPrefix="cc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="Server">

    <script language="javascript" type="text/javascript" src="../Javascript/Common.js"></script>

    <h2>
        <%=Resources.Language.Polls %>
    </h2>
    <ctrl:ctrlShowInfo ID="CtrlShowInfo" runat="server" />
    <div class="vSeparate">
        <span class="peBoxLeft"></span><span class="peBoxRight">
            <asp:Button ID="btnSavePollTop" runat="server" OnCommand="Poll_Command" CommandName="Save"
                Text="<%$Resources:Language,Save %>" />
            <asp:Button ID="btnNewPollTop" runat="server" OnCommand="Poll_Command" CommandName="New"
                Text="<%$Resources:Language,NewPoll %>" CausesValidation="false" />
            <asp:Button ID="btnDeletePollTop" runat="server" OnCommand="Poll_Command" CommandName="Delete"
                Text="<%$Resources:Language,Remove %>" CausesValidation="false" />
            <asp:Button ID="btnCancelTop" runat="server" OnCommand="Poll_Command" CommandName="Cancel"
                Text="<%$Resources:Language,Cancel %>" CausesValidation="false" />
        </span>
    </div>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%=Resources.Language.Polls %>:</span><span class="peBoxRight">
                <asp:DropDownList ID="ddlPolls" runat="server" AutoPostBack="true" CssClass="DropDownWide"
                    DataTextField="Name" DataValueField="IDPoll" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlPolls_SelectedIndexChanged">
                </asp:DropDownList>
            </span>
    </div>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%=Resources.Language.Lang %>:</span><span class="peBoxRight">
                <asp:DropDownList ID="ddlLanguage" runat="server" AutoPostBack="true" DataTextField="Name"
                    DataValueField="LanguageID" OnSelectedIndexChanged="ddlLanguage_SelectedIndexChanged"
                    CssClass="DropDownShort">
                </asp:DropDownList>
            </span>
    </div>
    <% if (lDateCreated.Text != string.Empty)
       { %>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%=Resources.Language.CreationDate%>:</span><span class="peBoxRight">
                <asp:Label ID="lDateCreated" runat="server"></asp:Label>
            </span>
    </div>
    <% }%>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%=Resources.Language.Title%>:</span><span class="peBoxRight">
                <asp:TextBox ID="tbName" runat="server" CssClass="TextInputWide"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvName" runat="server" ControlToValidate="tbName"
                    EnableClientScript="false" ErrorMessage="*"></asp:RequiredFieldValidator>
            </span>
    </div>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%=Resources.Language.Question%>:</span><span class="peBoxRight">
                <asp:TextBox ID="tbQuestion" runat="server" TextMode="MultiLine" CssClass="TextInputMultiline"></asp:TextBox>
                <asp:RequiredFieldValidator ID="rfvQuestion" runat="server" ControlToValidate="tbQuestion"
                    EnableClientScript="false" ErrorMessage="*"></asp:RequiredFieldValidator>
            </span>
    </div>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%=Resources.Language.Active %>:</span><span class="peBoxRight">
                <asp:CheckBox ID="cbIsActive" runat="server" />
            </span>
    </div>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%= Resources.Language.Category %>:</span><span class="peBoxRight">
                <asp:DropDownList ID="ddlCategory" runat="server" CssClass="DropDown">
                </asp:DropDownList>
            </span>
    </div>
    <div class="vSeparate">
        <span class="peBoxLeft">
            <%= Resources.Language.Answers %>:</span><span class="peBoxRight">
                <table class="cmsTables" style="width: 500px">
                    <tr>
                        <th style="width: 400px">
                            <%=Resources.Language.Answer%>
                        </th>
                        <th style="width: 50px">
                            <%=Resources.Language.CountOfVote%>
                        </th>
                        <th style="width: 50px">
                        </th>
                    </tr>
                    <asp:Repeater ID="rptAnswerPoll" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%# Eval("Answer") %>
                                </td>
                                <td>
                                    <%# Eval("Votes") %>
                                </td>
                                <td>
                                    <asp:LinkButton ID="lbEditAnswer" runat="server" OnCommand="Answer_Command" CommandName="Edit"
                                        CommandArgument="<%# ((ShopModel.PollAnswer)Container.DataItem).IDPollAnswer %>"
                                        Text="<%$ Resources:Language,Edit %>" CausesValidation="false"></asp:LinkButton>
                                    <asp:LinkButton ID="lbDeleteAnser" runat="server" OnCommand="Answer_Command" CommandName="Delete"
                                        CommandArgument="<%# ((ShopModel.PollAnswer)Container.DataItem).IDPollAnswer %>"
                                        Text="<%$ Resources:Language,Remove %>" CausesValidation="false"></asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                    <tr>
                        <td>
                            <asp:TextBox ID="tbAnswer" runat="server" CssClass="TextInputWide"></asp:TextBox>
                        </td>
                        <td>
                            -
                        </td>
                        <td>
                            <asp:HiddenField ID="hfEditedPollAnswerID" Value="" runat="server" />
                            <% if (hfEditedPollAnswerID.Value == string.Empty)
                               {%>
                            <asp:LinkButton ID="btnAddNewAnswer" runat="server" OnCommand="Answer_Command" CommandName="Add"
                                Text="<%$Resources:Language,Add %>" CausesValidation="false" />
                            <%}
                               else
                               { %>
                            <asp:LinkButton ID="btnSaveAnswer" runat="server" OnCommand="Answer_Command" CommandName="Save"
                                Text="<%$Resources:Language,Save %>" CausesValidation="false" />
                            <asp:LinkButton ID="btnCancelEditing" runat="server" OnCommand="Answer_Command" CommandName="Cancel"
                                Text="<%$Resources:Language,Cancel %>" CausesValidation="false" />
                            <%} %>
                        </td>
                    </tr>
                </table>
            </span>
    </div>
    <div class="vSeparate">
        <span class="peBoxLeft"></span><span class="peBoxRight">
            <asp:Button ID="btnSavePollBottom" runat="server" OnCommand="Poll_Command" CommandName="Save"
                Text="<%$Resources:Language,Save %>" OnClientClick="ScrollTop();" />
            <asp:Button ID="btnNewPollBottom" runat="server" OnCommand="Poll_Command" CommandName="New"
                Text="<%$Resources:Language,NewPoll %>" CausesValidation="false" OnClientClick="ScrollTop();" />
            <asp:Button ID="btnDeletePollBottom" runat="server" OnCommand="Poll_Command" CommandName="Delete"
                Text="<%$Resources:Language,Remove %>" CausesValidation="false" OnClientClick="ScrollTop();" />
            <asp:Button ID="btnCancelBottom" runat="server" OnCommand="Poll_Command" CommandName="Cancel"
                Text="<%$Resources:Language,Cancel %>" CausesValidation="false" OnClientClick="ScrollTop();" />
        </span>
    </div>
</asp:Content>
